package com.wuh.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.github.pagehelper.PageInfo;
import com.wuh.model.Link;
import com.wuh.service.LinkService;

@Controller
public class LinkController {

	@Autowired
    private LinkService linkService;
	
	@RequestMapping("/getLinks")
	public String getLinks(Link link,Model model) {
		link.setPageSize(5);
    	PageInfo<Link> pageInfo = linkService.getLinks(link);
		model.addAttribute("pageInfo",pageInfo);
		model.addAttribute("schLink",link);
    	
		return "system/sys_link";
	}
	
	@GetMapping("/delLinks")
	public String delLinks(Integer[] ids) {
		linkService.delLinks(ids);
    	
		return "redirect:/getLinks";
	}
	
	@RequestMapping("/addLink")
    public String addLink(Link link) {
		linkService.addLink(link);
    	
		return "redirect:/getLinks";
	}
	
	
}
